load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_test")

package(
    default_visibility = ["//visibility:private"],
)

cc_binary(
    name = "bench",
    srcs = [
        "bench.c",
    ],
    deps = [
        "//:event_core",
        "//:event_core_private_headers",
    ] + select({
        "@platforms//os:windows": [
            "//WIN32-Code:getopt",
        ],
        "//conditions:default": [],
    }),
)

cc_binary(
    name = "bench_cascade",
    srcs = [
        "bench_cascade.c",
    ],
    deps = [
        "//:event_core",
        "//:event_core_private_headers",
    ] + select({
        "@platforms//os:windows": [
            "//WIN32-Code:getopt",
        ],
        "//conditions:default": [],
    }),
)

cc_binary(
    name = "bench_http",
    srcs = [
        "bench_http.c",
    ],
    deps = [
        "//:event_core",
        "//:event_extra",
    ],
)

cc_binary(
    name = "bench_httpclient",
    srcs = [
        "bench_httpclient.c",
    ],
    deps = [
        "//:event_core",
        "//:event_core_private_headers",
        "//:event_extra",
    ],
)

cc_test(
    name = "regress",
    srcs = [
        "regress.c",
        "regress.gen.c",
        "regress.gen.h",
        "regress.h",
        "regress_buffer.c",
        "regress_bufferevent.c",
        "regress_dns.c",
        "regress_et.c",
        "regress_finalize.c",
        "regress_http.c",
        "regress_listener.c",
        "regress_main.c",
        "regress_minheap.c",
        "regress_rpc.c",
        "regress_ssl.c",
        "regress_testutils.c",
        "regress_testutils.h",
        "regress_thread.c",
        "regress_thread.h",
        "regress_util.c",
        "regress_zlib.c",
        "tinytest.c",
        "tinytest.h",
        "tinytest_local.h",
        "tinytest_macros.h",
    ] + select({
        "@platforms//os:windows": [
            "regress_iocp.c",
        ],
        "//conditions:default": [],
    }),
    tags = [
        # This test does not pass even when using the official build
        # system, so it is tagged to be run manually only.
        "manual",
        "requires_openssl",
    ],
    deps = [
        "//:event_core",
        "//:event_core_private_headers",
        "//:event_extra",
        "//:event_extra_private_headers",
        "//:event_openssl",
        "//:event_openssl_private_headers",
        "//:event_pthreads",
        "@openssl//:crypto",
        "@openssl//:ssl",
        "@zlib//:z",
    ],
)

cc_test(
    name = "test-changelist",
    srcs = [
        "test-changelist.c",
    ],
    deps = [
        "//:event_core",
        "//:event_core_private_headers",
    ],
)

cc_test(
    name = "test-closed",
    srcs = [
        "test-closed.c",
    ],
    deps = [
        "//:event_core",
        "//:event_core_private_headers",
    ],
)

cc_test(
    name = "test-dumpevents",
    srcs = [
        "test-dumpevents.c",
    ],
    deps = [
        "//:event_core",
        "//:event_core_private_headers",
    ],
)

cc_test(
    name = "test-eof",
    srcs = [
        "test-eof.c",
    ],
    deps = [
        "//:event_core",
        "//:event_core_private_headers",
    ],
)

cc_test(
    name = "test-fdleak",
    srcs = [
        "test-fdleak.c",
    ],
    deps = [
        "//:event_core",
    ],
)

cc_test(
    name = "test-init",
    srcs = [
        "test-init.c",
    ],
    deps = [
        "//:event_core",
    ],
)

cc_test(
    name = "test-ratelim",
    srcs = [
        "test-ratelim.c",
    ],
    deps = [
        "//:event_core",
        "//:event_core_private_headers",
    ],
)

cc_test(
    name = "test-time",
    srcs = [
        "test-time.c",
    ],
    deps = [
        "//:event_core",
        "//:event_core_private_headers",
    ],
)

cc_test(
    name = "test-weof",
    srcs = [
        "test-weof.c",
    ],
    deps = [
        "//:event_core",
        "//:event_core_private_headers",
    ],
)

cc_test(
    name = "test-config",
    srcs = [
        "test-config.c",
    ],
    deps = [
        "//:event_core",
    ],
)
